import com.smart.domain.Express;
import com.smart.domain.User;
import com.smart.infer.expressPieceInt;
import com.smart.infer.userInt;
import com.smart.infer.userPubInt;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:schema/smart-context4.xml")

public class usertest {
    @Autowired
    private userInt mapper;
    @Autowired
    private userPubInt mapper2;
    @Autowired
    private expressPieceInt m;
    @Test
    public void con(){
       int n= mapper.count("ll");
        System.out.print(n);
    }

    @Test
    public void find(){
        int score=mapper.findScore("aa");
        System.out.print(score);
    }

    @Test
    public void insert(){
        User user = new User();
        user.setUsername("aa");
        user.setPhonenumber("1234560");
        user.setAddress("南苑四号公寓楼");
        user.setPassword("123456");
        user.setScore(1);
        mapper.reg(user);
    }

    @Test
    public  void ins(){
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
        Date date=new Date();
        String dateString = df.format(date);
        System.out.print(dateString);
        Express express=new Express();
        express.setUserid("无");
        express.setE_singernum("无");
        express.setE_number("293273");
        express.setE_singer("无");
        express.setE_status("0");
        express.setE_time(dateString);
        express.setE_tellnumber("1822763");
        express.setE_address("an7");
        express.setE_addressee("chen");
        express.setE_code("2-3-4");
        express.setE_esc("zt");
        express.setE_leadtime("无");
        express.setE_user("无");
        mapper2.insert(express);
    }
    @Test
    public void de(){
        mapper2.delete("123454322");

    }

    @Test
    public void check(){
        String username="aa";
        User user=mapper.log(username);
        System.out.print(user.toString());
    }
    @Test
    public void up(){
        String n="123454321";
        String name="cc";
        String number="123456789";
        mapper2.update(n,name,number);

    }
    @Test
    public void select(){
        String esc="百世";String e_add="南苑7号宿舍楼";
        List<Express> e=m.selectExpressByAddress(e_add,esc,"徐");
        System.out.print(e.toString());
    }

    @Test
    public void aa(){
        String name="aa";
        List list=mapper2.findAllByUser(name);
        System.out.print(list.toString());
    }
}
